import * as apis from '@/apis/modules/withdrawals.js';

const withdrawals = {
	namespaced: true,
	state: {
		accountInfo: {
		}
	},
	mutations: {
		save(state, {field, payload}) {
		  if (Object.prototype.toString.call(payload) === '[object Object]') {
			state[field] = { ...state[field], ...payload }
		  } else {
			state[field] = payload
		  }
		}
	},
	actions: {
		getAccountInfo({ commit }) {
			apis.getAccountInfo()
				.then(({data}) => {
					commit('save', {field: 'accountInfo', payload: data})
				})
			},
	
			withdraw({ commit }, payload) {
				return api.withdraw(payload)
			}
	}
}

export default withdrawals